/** 
 * Copyright (C), 2010-2012, TIETIAO Software Co.,Ltd. ALL RIGHTS RESERVED. 
 * File name:BgCommentAction.java
 * Version:1.0
 * Date:2012-1-3
 * Description: 
 * author:zhijian.zhang
 */
package com.tietiao.action.bg;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.tietiao.common.action.BaseAction;
import com.tietiao.common.json.JsonControllerHelper;
import com.tietiao.common.util.PageModel;
import com.tietiao.dao.model.UserComment;
import com.tietiao.service.comment.CommentService;

@Controller
@Scope("prototype")
@SuppressWarnings("serial")
public class BgCommentAction extends BaseAction {
	@Resource
	// 评论service
	private CommentService commentService;
	// 表单信息
	private UserComment comment;
	// 用户评论列表
	private List<UserComment> userComments;
	// 评论ID数组
	private Integer[] commentIds;

	public Integer[] getCommentIds() {
		return commentIds;
	}

	public void setCommentIds(Integer[] commentIds) {
		this.commentIds = commentIds;
	}

	public UserComment getComment() {
		return comment;
	}

	public void setComment(UserComment comment) {
		this.comment = comment;
	}

	public List<UserComment> getUserComments() {
		return userComments;
	}

	public void setUserComments(List<UserComment> userComments) {
		this.userComments = userComments;
	}

	// 进入评论主页
	public String index() {
		return dispatcher("/jsp/bg/comment/comment_list.jsp");
	}

	// 加载数据
	public String loadList() throws Exception {

		PageModel<UserComment> usercomments = commentService.getUserComments(
				comment, getStart(), getLimit(), getSort(), getDir());
		JsonControllerHelper.writePageModelToResponse(response, usercomments);
		return null;
	}

	// 删除数据
	public String del() {
		commentService.delUserComments(commentIds);
		return null;
	}
}
